package com.tongji.diy.model.furniturePlacementOptimization
{
	import com.tongji.diy.event.furnitureOptimizationEvent.OptimizationAddFurnitureEvent;
	import com.tongji.diy.event.furnitureOptimizationEvent.StartIntegrateEvent;
	import com.tongji.diy.model.RoomDataModel;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.Bedding;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.BeddingNearby;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.ComfortableFurniture;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.Facal;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.FacalCompound;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.FacalContainee;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.FacalContainer;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.FacalSignal;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.FurnitureBase;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.NoAccessibleFurniture;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.SLbase;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.Seat;
	import com.tongji.diy.model.furniturePlacementOptimization.assembleComplement.SeatNearby;
	
	import flash.utils.getTimer;
	
	import org.robotlegs.mvcs.Actor;
	
	public class AssembleModel extends Actor
	{		
		[Inject]
		public var roomModel:RoomDataModel;
		
		private var _facalNum:int = 0;
		private var _seatNum:int = 0;
		private var _seatNearbyNum:int = 0;
		private var _beddingNum:int = 0;
		private var _beddingNearByNum:int = 0;
		private var _comfortableNum:int = 0;
		private var _noAccessibleNum:int = 0;		
		
		private var _facalList:Vector.<Facal> = new Vector.<Facal>;
		private var _seatList:Vector.<Seat> = new Vector.<Seat>;
		private var _beddingList:Vector.<Bedding> = new Vector.<Bedding>;
		private var _beddingNearbyList:Vector.<BeddingNearby> = new Vector.<BeddingNearby>;
		private var _seatNearbyList:Vector.<SeatNearby> = new Vector.<SeatNearby>;
		private var _noAccessibleList:Vector.<NoAccessibleFurniture> = new Vector.<NoAccessibleFurniture>;
		private var _comfortableList:Vector.<ComfortableFurniture> = new Vector.<ComfortableFurniture>;
		
		private var _blocks:Vector.<Vector.<FurnitureBase> > = new Vector.<Vector.<FurnitureBase>>;
		
		private var _newAddFurnitureIndex:int = -1;
		private var _searchIndex:int = -1;
		private var _searchClass:int = -1;
		
		public function AssembleModel()
		{
			super();
		}
		
		public function assemble():void
		{
			/*trace("&&&&&");
			trace("facal");
			print(_facalList);
			trace("seat");
			print(_seatList);
			trace("seatnear");
			print(_seatNearbyList);
			trace("bedding");
			print(_beddingList);
			trace("beddingnear");
			print(_beddingNearbyList);
			trace("no");
			print(_noAccessibleList);
			trace("comfortable");
			print(_comfortableList);
			trace("&&&&&")*/
			
			trace("timeStartAssemble",getTimer());
			if(_facalList.length)
				facalContaineeSearchContainer();
			if(_facalList.length)
				remainingFacalHandler();
	
			if(_blocks.length)
			{
				facalSearchSLbase();
				if(_beddingList.length)
					buildBeddingBaseBlock();
				
				if(_beddingList.length)
				{
					buildBeddingBaseBlock();
				}
				if(_seatList.length)
				{
					buildSeatBaseBlock();
				}
				
				SLSearchNearby();
			}
			
			if(_beddingList.length)
			{
				buildBeddingBaseBlock();
			}
			if(_seatList.length)
			{
				buildSeatBaseBlock();
			}
			SLSearchNearby();
			trace("timefinishAssemble",getTimer());
			
			
			/*trace("&&&&&");
			trace("facal");
			print(_facalList);
			trace("seat");
			print(_seatList);
			trace("seatnear");
			print(_seatNearbyList);
			trace("bedding");
			print(_beddingList);
			trace("beddingnear");
			print(_beddingNearbyList);
			trace("no");
			print(_noAccessibleList);
			trace("comfortable");
			print(_comfortableList);
			trace("&&&&&")
			
			trace("+++++_blocks+++++")
			for(var i:int = 0;i < _blocks.length; i++)
			{
				print(_blocks[i]);
				
			}
			trace("+++++_blocks++++")*/
			//开始进入集成状态
			dispatch(new StartIntegrateEvent(StartIntegrateEvent.STAR_INTEGRATE));
			
//			var blockLayouts:Vector.<BlockLayoutConstructor> = new Vector.<BlockLayoutConstructor>;
//			
//			for(i = 0; i < _blocks.length; i++)
//			{
//				blockLayouts.push(new BlockLayoutConstructor(roomModel.rooms[0],_blocks[i]));
//				showLayout(blockLayouts[blockLayouts.length -1]);
//			}
			
		}
		
		
		
		private function buildBeddingBaseBlock():void
		{
			var v:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;
			while(_beddingList.length)
			{
				v.push(_beddingList.shift());					
			}
			_blocks.push(v);
		}
		
		private function buildSeatBaseBlock():void
		{
			var v:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;
			while(_seatList.length)
			{	
				v.push(_seatList.shift());					
			}
			_blocks.push(v);
		}
		
		private function statistics():void
		{
			_facalNum = _facalList.length;
			_seatNum = _seatList.length;
			_seatNearbyNum = _seatNearbyList.length;
			_beddingNum = _beddingList.length;
			_beddingNearByNum = _beddingNearbyList.length;
			_noAccessibleNum = _noAccessibleList.length;
			_comfortableNum = _comfortableList.length;
		}
		
		private function facalSearchSLbase():void
		{
			var blocksCorrNumVector:Vector.<Number> = new Vector.<Number>;
			for(var i:int = 0; i < _blocks.length; i++)
			{
				blocksCorrNumVector.push(0);
				for(var j:int = 0; j < _blocks[i].length; j++)
				{
					if(_blocks[i][j] is Facal)
					{
						var facal:Facal = _blocks[i][j] as Facal;	
						blocksCorrNumVector[i] += facalSearchSLLoopA(facal, _blocks[i]);
					}
				}
			}
			
			facalSearchSLLoopB();
			
			
			//执行第一遍循环，找出较为合适的seat，返回值是相应的facal找到seat后剩余的corrNum
			function facalSearchSLLoopA(facal:Facal, block:Vector.<FurnitureBase>):Number
			{
				var corrNum:int = facal.correspondingNum;
				
				for(var i:int = 0; i < facal.SLlist.length; i++)
				{
					var index:int = 0;
					_searchClass = facal.SLlist[i].furnitureClass;
					var v:Vector.<Seat> = _seatList.filter(searchFilterCallBack);
					
					while(v.length && corrNum > 0 && index <= v.length)
					{
						var sl:SLbase = v.shift();
						corrNum -= sl.peopleNum;
						if(corrNum >= 0)
						{
							block.push(sl);
							_seatList.splice(_seatList.indexOf(sl),1);
							--index;
						}
						else
						{
							corrNum += sl.peopleNum;
						}
						index ++;
					}
				}
				return corrNum;
			}
			//第二遍循环找出满足facal的次优的seat
			function facalSearchSLLoopB():void
			{
				for(var i:int = 0; i < blocksCorrNumVector.length; i++)
				{
					if(blocksCorrNumVector[i] > 0)
					{
						var corrNum:int = blocksCorrNumVector[i];
						//首先先找坐具的以满足facal对corrNum的需求
						var j:int = 0;
						while(_seatList.length && j < _seatList.length)
						{
							corrNum -= _seatList[j].peopleNum;
							if(corrNum >= 0)
							{
								_blocks[i].push(_seatList[j]);
								_seatList.splice(j,1);
								--j;
							}
							else
							{
								corrNum += _seatList[j].peopleNum;
							}
							++j;
						}
						//再找卧具以满足需求
						j = 0;
						if(corrNum > 0 && _blocks[i].every(seatEvery))
						{
							while(_beddingList.length && j < _beddingList.length)
							{
								corrNum -= _beddingList[j].peopleNum;
								if(corrNum >= 0)
								{
									_blocks[i].push(_beddingList[j]);
									_beddingList.splice(j,1);
									--j;
								}
								else
								{
									corrNum += _beddingList[j].peopleNum;
								}
								++j;
							}
							
						}
					}
				}
			}
			
		}		
		
		private function remainingFacalHandler():void
		{
			while(_facalList.length)
			{
				var v:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;
				v.push(_facalList[0]);
				_facalList.splice(0,1);
				_blocks.push(v);
			}				
		}
		
		private function SLSearchNearby():void
		{
			loopA();
			if(_seatNearbyList.length)
				loopB(_seatNearbyList, seatEvery);
			if(_beddingNearbyList.length)
				loopB(_beddingNearbyList, beddingEvery);
			
			//最适合循环
			function loopA():void
			{
				var seatnbv:Vector.<SeatNearby>;
				var beddingnbv:Vector.<BeddingNearby>;
				for(var i:int = 0; i < _blocks.length; i++)
				{
					for(var j:int = 0; j < _blocks[i].length; j++)
					{
						if(_blocks[i][j] is SLbase)
						{
							var sl:SLbase = _blocks[i][j] as SLbase;
							for(var k:int = 0; sl.priorList && k < sl.priorList.length; k++)
							{
								_searchClass = sl.priorList[k].furnitureClass; 
								if(_blocks[i].every(searchEveryCallBack))
								{
									_searchClass = sl.priorList[k].furnitureClass;
									seatnbv = _seatNearbyList.filter(searchFilterCallBack);
									_searchClass = sl.priorList[k].furnitureClass;
									beddingnbv = _beddingNearbyList.filter(searchFilterCallBack);
									
									if(seatnbv.length && beddingnbv.length)
									{
										trace("分类错误：同一个class分给了不同的nearby");
									}
									
									if(seatnbv.length)
									{
										var s:SeatNearby = seatnbv.shift();
										_blocks[i].push(s);
										_seatNearbyList.splice(_seatNearbyList.indexOf(s),1);
									}
									else if(beddingnbv.length)
									{
										var b:BeddingNearby = beddingnbv.shift();
										_blocks[i].push(b);
										_beddingNearbyList.splice(_beddingNearbyList.indexOf(b),1);
									}
								}
							}
						}
					}
				}
			}
		
			function loopB(SLv:*, everyfunc:Function):void
			{
				var count:int = 0;
				while(SLv.length && count < 30)
				{
					var index:int = Math.floor(Math.random()*_blocks.length);
					if(!_blocks[index].every(everyfunc))
					{
						_blocks[index].push(SLv.shift());
					}
					count++;
				}
				
				while(SLv.length)
				{
					trace("随机过程失效，启用强制匹配")
					
					for(var i:int = 0; i < _blocks.length; i++)
					{
						if(!_blocks[i].every(everyfunc))
						{
							_blocks[i].push(SLv.shift());
						}
					}					
				}
			}
		}
		
		private function facalContaineeSearchContainer():void
		{
			loopA();
			loopB();
			
			//第一遍循环先找最为贴合的facalcontainer，containee组合
			function loopA():void
			{
				var i:int = 0;
				while(i < _facalList.length)
				{
					if(_facalList[i] is FacalContainee)
					{
						var containee:FacalContainee = _facalList[i] as FacalContainee;
						var innerEndLoop:Boolean = false;
						for(var j:int = 0; !innerEndLoop &&  j < containee.containerList.length; j++)
						{
							_searchClass = containee.containerList[j].furnitureClass;
							if(!_facalList.every(searchEveryCallBack))
							{
								var v:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;
								v.push(new FacalCompound(_facalList[_searchIndex] as FacalContainer, _facalList[i] as FacalContainee));
								_blocks.push(v);
								
								
								if(i < _searchIndex)
								{
									var temp:int = i;
									i = _searchIndex;
									_searchIndex = temp;
								}
								
								
								
								_facalList.splice(_searchIndex,1);
								_facalList.splice(i - 1,1);
								i = -1;
								innerEndLoop = true;
							}
						}
						
					}
					i++;
				}
			}
				
				
			//第二遍找较为不适合的container，containee组合
			function loopB():void
			{
				var i:int = 0;
				while(i < _facalList.length)
				{
					if(_facalList[i] is FacalContainee)
					{
						var containee:FacalContainee = _facalList[i] as FacalContainee;
						var innerEndLoop:Boolean = false;
						for(var j:int = 0; !innerEndLoop && j < _facalList.length; j++)
						{
							if(_facalList[j] is FacalContainer)
							{
								var v:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;
								v.push(new FacalCompound(_facalList[j] as FacalContainer, _facalList[i] as FacalContainee));
								_blocks.push(v);
								
								
								if(i < j)
								{
									var temp:int = i;
									i = j;
									j = temp;
								}
								
								
								
								_facalList.splice(j,1);
								_facalList.splice(i - 1,1);
								innerEndLoop = true;
								i = -1;
							}
						}
					}
					i++;
				}
			}
		}
		
		
		
		
		//该函数是回调函数，应用于vector.every函数，该函数的会修改_searchFacalContainerIndex 的值，
		//使其指向第一个找到对应类型的facalcontainer在facallist中的索引，并将默认搜索的_searchFacalContainerClass值变为默认值-1
		/*private function searchContainerCallBack(item:Object, index:int, v:Vector.<Facal>):Boolean
		{
			if(item is FacalContainer && (item as FacalContainer).furnitureClass == _searchFacalContainerClass)
			{
				_searchFacalContainerIndex = index;
				_searchFacalContainerClass = -1;
				return false;
			}
			return true;
		}*/
		
		private function beddingEvery(item:Object, index:int, v:*):Boolean
		{
			if(item is Bedding)
				return false;
			else
				return true;
		}
		
		private function seatEvery(item:Object, index:int, v:*):Boolean
		{
			if(item is Seat)
				return false;
			else
				return true;
		}
		
		private function searchFilterCallBack(item:Object, index:int, v:*):Boolean
		{
			if((item as FurnitureBase).furnitureClass == _searchClass)
				return true
			else
				return false;
		}
		
		private function searchEveryCallBack(item:Object, index:int, v:*):Boolean
		{
			if((item as FurnitureBase).furnitureClass == _searchClass)
			{
				_searchIndex = index;
				_searchClass = -1;
				return false;
			}
			return true;
		}
		
		public function addFurniture(e:OptimizationAddFurnitureEvent):void
		{
			_newAddFurnitureIndex = e.furnitureIndex;
			var fur:FurnitureBase = buildClass(e);
			var addSign:Boolean = true;
			if(fur is Facal)
			{
				addSign = _facalList.every(addCompare);
				if(addSign)
					_facalList.push(fur);
			}
			else if(fur is Seat)
			{
				addSign = _seatList.every(addCompare);
				if(addSign)
					_seatList.push(fur);
			}
			else if(fur is Bedding)
			{
				addSign = _beddingList.every(addCompare);
				if(addSign)
					_beddingList.push(fur);
			}
			else if(fur is BeddingNearby)
			{
				addSign = _beddingNearbyList.every(addCompare);
				if(addSign)
					_beddingNearbyList.push(fur);
			}
			else if(fur is SeatNearby)
			{
				addSign = _seatNearbyList.every(addCompare);
				if(addSign)
					_seatNearbyList.push(fur);
			}
			else if(fur is NoAccessibleFurniture)
			{
				addSign = _noAccessibleList.every(addCompare);
				if(addSign)
					_noAccessibleList.push(fur);
			}
			else if(fur is ComfortableFurniture)
			{
				addSign = _comfortableList.every(addCompare);
				if(addSign)
					_comfortableList.push(fur);
			}
			
		}
		
		
		//print函数仅仅适用于测试使用
		private function print(v:*):void
		{	
			trace("*******")
			for each(var i:FurnitureBase in v)
			{
				if(!(i is FacalCompound))
					trace("index",i.furnitureIndex,"class",i.furnitureClass);
				else
				{
					trace("index",(i as FacalCompound).container.furnitureIndex,"class",(i as FacalCompound).container.furnitureClass);
					trace("index",(i as FacalCompound).containee.furnitureIndex,"class",(i as FacalCompound).containee.furnitureClass);
				}
			}
		
		}
		
		private function addCompare(item:Object, index:int, vector:*):Boolean
		{
			if((item as FurnitureBase).furnitureIndex == _newAddFurnitureIndex)
				return false;
			return true;
		}
		
		private function buildClass(e:OptimizationAddFurnitureEvent):FurnitureBase
		{
			var slv:Vector.<SLbase> = new Vector.<SLbase>;
			var vov:Vector.<Boolean> = new Vector.<Boolean>;//每边可见性
			var vdv:Vector.<Number> = new Vector.<Number>;//可见性距离
			var clv:Vector.<FacalContainer> = new Vector.<FacalContainer>;//facalContainee的container优先表
			var slnbv:Vector.<FurnitureBase> = new Vector.<FurnitureBase>;//坐卧具优先列表
			var cnv:Vector.<int> = new Vector.<int>;//facal 每边人数表
			switch(e.furnitureClass)
			{
				case OptimizationParameter.BED:
					slnbv.push(new FurnitureBase(-1,OptimizationParameter.BEDSTAND,false), new FurnitureBase(-1,OptimizationParameter.CABINET,false));
					return new Bedding(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth,2,slnbv);
					break;
				case OptimizationParameter.SINGLE_BED:
					slnbv.push(new FurnitureBase(-1,OptimizationParameter.BEDSTAND,false), new FurnitureBase(-1,OptimizationParameter.CABINET,false));
					return new Bedding(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth,1,slnbv);
					break;
				case OptimizationParameter.DESK:
					slv.push(new SLbase(-1,OptimizationParameter.OFFICE_CHAIR,false));
					vov.push(true,false,false,false);
					vdv.push(10,0,0,0);
					cnv.push(1,0,0,0);
					return new FacalContainer(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth, cnv,slv,vov,vdv); 
					break;
				case OptimizationParameter.DINING_TABLE:
					slv.push(new SLbase(-1,OptimizationParameter.CHAIR,false));
					vov.push(true,true,true,true);
					vdv.push(10,10,10,10);
					cnv.push(2,2,1,1);
					return new FacalContainer(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth, cnv,slv,vov,vdv); 
					break;
				case OptimizationParameter.CHAIR:
					return new Seat(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth,1);
					break;
				case OptimizationParameter.OFFICE_CHAIR:
					slnbv.push(new FurnitureBase(-1, OptimizationParameter.BIN,false));
					return new Seat(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth,1,slnbv);
					break;
				case OptimizationParameter.TV:
					slv.push(new SLbase(-1,OptimizationParameter.MULITI_SOFA,false),new SLbase(-1,OptimizationParameter.SINGLE_SOFA,false));
					vov.push(true,false,false,false);
					vdv.push(100,0,0,0);
					clv.push(new FacalContainer(-1,OptimizationParameter.TV_RACK,false));
					cnv.push(4,0,0,0);
					return new FacalContainee(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth, cnv, slv, vov, vdv, clv);
					break;
//				case OptimizationParameter.CEILING_LAMP:
//					return new ComfortableFurniture(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth);
//					break;
				case OptimizationParameter.SINGLE_SOFA:
					slnbv.push(new FurnitureBase(-1, OptimizationParameter.SIDE_TABLE,false), new FurnitureBase(-1, OptimizationParameter.BIN,false),  new FurnitureBase(-1, OptimizationParameter.BOOKSHELF,false));
					return new Seat(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth,1,slnbv);
					break; 
				case OptimizationParameter.MULITI_SOFA:
					//trace("MULITI_SOFA",e.width,e.length);
					slnbv.push(new FurnitureBase(-1, OptimizationParameter.SIDE_TABLE,false), new FurnitureBase(-1, OptimizationParameter.BIN,false), new FurnitureBase(-1, OptimizationParameter.BOOKSHELF,false));
					return new Seat(e.furnitureIndex,e.furnitureClass,false,e.length,e.width,e.heigth,2,slnbv);
					break;
				case OptimizationParameter.CABINET:
					vdv.push(30,0,0,0);
					//trace("CABINET",e.width,e.length)
					return new BeddingNearby(e.furnitureIndex,e.furnitureClass,vdv,true,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.VASE:
					return new NoAccessibleFurniture(e.furnitureIndex,e.furnitureClass,false,50,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.SIDE_TABLE:
					vdv.push(10,10,10,10);
					return new SeatNearby(e.furnitureIndex,e.furnitureClass,vdv,false,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.BEDSTAND:
					vdv.push(10,0,0,0);
					return new BeddingNearby(e.furnitureIndex,e.furnitureClass,vdv,true,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.FIREPLACE:
					slv.push(new SLbase(-1,OptimizationParameter.MULITI_SOFA,false), new SLbase(-1,OptimizationParameter.SINGLE_SOFA,false));
					vov.push(true,false,false,false);
					vdv.push(80,0,0,0);
					cnv.push(4,0,0,0);
					return new FacalSignal(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth,cnv,slv,vov,vdv);
					break;
				case OptimizationParameter.BOOKSHELF:
					vdv.push(50,0,0,0);
					return new SeatNearby(e.furnitureIndex,e.furnitureClass,vdv,true,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.TV_RACK:
					slv.push(new SLbase(-1,OptimizationParameter.MULITI_SOFA,false), new SLbase(-1,OptimizationParameter.SINGLE_SOFA,false));
					vov.push(true,false,false,false);
					vdv.push(300,0,0,0);
					cnv.push(2,0,0,0);//修改过原值应该是4.0.0.0
					return new FacalContainer(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth,cnv,slv,vov,vdv);
					break;
				case OptimizationParameter.BIN:
					vdv.push(10,10,10,10);
					return new SeatNearby(e.furnitureIndex,e.furnitureClass,vdv,false,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.LAPTOP:
					slv.push(new SLbase(-1,OptimizationParameter.OFFICE_CHAIR,false),new SLbase(-1,OptimizationParameter.CHAIR,false));
					vov.push(true,false,false,false);
					vdv.push(30,0,0,0);
					clv.push(new FacalContainer(-1,OptimizationParameter.DESK,false));
					cnv.push(1,0,0,0);
					return new FacalContainee(e.furnitureIndex,e.furnitureClass,true,e.length,e.width,e.heigth, cnv, slv, vov, vdv, clv);
					break;
				case OptimizationParameter.BABAYBED:
					vdv.push(50,0,50,50);
					return new BeddingNearby(e.furnitureIndex,e.furnitureClass,vdv,false,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.CEILING_LAMP:
					return new NoAccessibleFurniture(e.furnitureIndex,e.furnitureClass,false,OptimizationParameter.LIGHT_RADIATION_RADIUS,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.FLOOR_LAMP:
					return new NoAccessibleFurniture(e.furnitureIndex,e.furnitureClass,false,OptimizationParameter.LIGHT_RADIATION_RADIUS,e.length,e.width,e.heigth);
					break;
				case OptimizationParameter.AIRCONDITION:
					return new NoAccessibleFurniture(e.furnitureIndex,e.furnitureClass,true,OptimizationParameter.AIRCONDITION_RADIATION_RADIUS,e.length,e.width,e.heigth);
					break;
				default:
					return null;
					break;
			}
		}
		
		public function get blocks():Vector.<Vector.<FurnitureBase>>
		{
			return _blocks;
		}
		
		public function get noAccessFurniture():Vector.<NoAccessibleFurniture>
		{
			return _noAccessibleList;
		}
	}
}